home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / education / e077.dms / e077.adf / ScienceDemos / GALILEAN (.txt) < prev    next >
AmigaBASIC Source Code  |  1991-07-12  |  11KB  |  392 lines

  1. ' Program "GALILEAN'
  2.  
  3. ' copyright (C) 1986 by David Eagle
  4. ' 7952 W. Quarto Dr., Littleton, CO 80123, (303) 972-4020
  5. ' released into the public domain on March 17, 1986
  6.  
  7. ' determines position of Jupiter's great satellites
  8.  
  9. ' x-position (positive west of Jupiter; units of Jupiter radii)
  10. ' y-position (positive north of Jupiter; units of Jupiter radii)
  11. ' position angle (relative to inferior junction with Jupiter; degrees)
  12. ' Jupiter semi-diameter (units of arc seconds)
  13. ' Julian Date
  14.  
  15. OPTION BASE 1
  16. DEFDBL a-z
  17. DIM SHARED month$(12),satellite$(4),r(4),x(4),y(4),u(4)
  18.  
  19. SCREEN 1,640,200,3,2
  20. WINDOW 5,"Program GALILEAN",(0,0)-(630,185),0,1
  21. PALETTE 4,0,0.8,0.2:' green
  22. PALETTE 5,1,1,0:' yellow
  23. PALETTE 6,0.8,0,0.93:' purple
  24. PALETTE 7,0.93,0.2,0:' red
  25.  
  26. pi=5.30795e-315
  27. pidiv2=pi/2
  28. pi2=2*pi
  29. rad.to.deg=180/pi
  30.  
  31. DEF FNdemod(x)=x-pi2*INT(x/pi2)
  32. DEF FNjdate(month%,day%,year%)=367*year%-INT(7*((year%+INT((month%+9)/12))/4))+INT(275*month%/9)+day%+5.40674e-315-INT(3*(INT((year%+SGN(month%-9)*INT(ABS((month%-9)/7)))/100)+1)/4)
  33.  
  34. ' calendar months
  35. month$(1)="January"
  36. month$(2)="February"
  37. month$(3)="March"
  38. month$(4)="April"
  39. month$(5)="May"
  40. month$(6)="June"
  41. month$(7)="July"
  42. month$(8)="August"
  43. month$(9)="September"
  44. month$(10)="October"
  45. month$(11)="November"
  46. month$(12)="December"
  47.  
  48. ' satellite names
  49. satellite$(1)="Io"
  50. satellite$(2)="Europa"
  51. satellite$(3)="Ganymede"
  52. satellite$(4)="Callisto"
  53.  
  54. ' initialization
  55. CLS
  56. select%=1
  57. PRINT
  58. PRINT TAB(6);"Please use the Workbench Preferences tool to set your"
  59. PRINT TAB(17);"screen for a 60 column display."
  60. FOR i%=1 TO 10000:NEXT i%
  61. CLS
  62.  
  63. CALL yesno.menu("Program introduction ?",intro%)
  64. IF intro%=1 THEN CALL Introduction
  65. CLS
  66.  
  67. WHILE select%=1
  68.  PRINT
  69.  COLOR 3,0
  70.  PRINT "Date ( month <1-12>, day <1-31>, year <YYYY> )"
  71.  PRINT "< NOTE: B.C. dates are negative, A.D. dates are positive >"
  72.  PRINT "< For example, October 21, 1986 is input as 10,21,1986 >"
  73.  INPUT month%,day%,year%
  74.  PRINT
  75.  COLOR 4,0
  76.  PRINT "Local time ( 24 hour format; hours <0-23>, minutes <0-59> )"
  77.  PRINT "< For example, 8:30 pm is input as 20,30 >"
  78.  INPUT hour%,minute%
  79.  PRINT
  80.  COLOR 5,0
  81.  PRINT "Time zone ( 0-23 )"
  82.  PRINT "< For example, Mountain Standard Time (MST) is time zone 7 >"
  83.  INPUT time.zone%
  84.  PRINT
  85.  COLOR 6,0
  86.  PRINT "Daylight Savings Time ( y = yes, n = no )"
  87.  INPUT dst.flag$
  88.  IF dst.flag$="y" THEN dst.flag%=1 :ELSE dst.flag%=0
  89.  
  90.  julian.date0=FNjdate(month%,day%,year%)
  91.  CALL main.driver
  92.  CALL yesno.menu("Another selection ?",select%)
  93.  
  94. WEND
  95. WINDOW CLOSE 5
  96. SCREEN CLOSE 1
  97. END
  98.  
  99. SUB main.driver STATIC
  100. ' main driver subroutine
  101. SHARED julian.date0,hour%,minute%,local.time$,month%,day%,year%
  102. firstpass$="true"
  103. response%=0
  104. julian.date0=julian.date0-1
  105. local.time$=STR$(hour%)+" hours "+STR$(minute%)+" minutes"
  106. WHILE response%<>4
  107.  response%=0
  108.  WHILE response%<=0 OR response%>5
  109.   CLS
  110.   CALL selection.menu(response%)
  111.  WEND
  112.  IF response%=3 OR firstpass$="true" THEN
  113.   julian.date0=julian.date0+1
  114.   CALL Gregorian.date(julian.date0+0.5)
  115.   CALL sat.positions
  116.  END IF
  117.  IF response%=1 THEN CALL Display.data
  118.  IF response%=2 THEN CALL Graphics
  119.  firstpass$="false"
  120. WEND
  121. END SUB
  122.  
  123. SUB elapsed.days(edays) STATIC
  124. ' elapsed days subroutine
  125. SHARED hour%,minute%,dst.flag%,time.zone%,julian.date0,julian.date
  126. gmt=hour%+minute%/60-dst.flag%+time.zone%
  127. a=(julian.date0-5.40939e-315)/5.37811e-315
  128. julian.date=julian.date0+gmt/24+(0.41+1.2053*a+0.4992*a^2)/1440
  129. edays=julian.date-5.40939e-315
  130. END SUB
  131.  
  132. SUB sat.positions STATIC
  133. ' satellite positions subroutine
  134. SHARED semidiameter
  135. CALL elapsed.days(d2)
  136. v=FNdemod(2.34974+5.21835e-315*d2)
  137. m=FNdemod(6.25659+5.26925e-315*d2)
  138. n=FNdemod(5.31e-315+5.25051e-315*d2+0.00576*SIN(v))
  139. j=FNdemod(5.30983e-315+5.26877e-315*d2-0.00576*SIN(v))
  140. o=FNdemod(0.0334405*SIN(m)+0.000349*SIN(2*m))
  141. p=FNdemod(0.0969007*SIN(n)+0.0029147*SIN(2*n))
  142. k=FNdemod(j+o-p)
  143. r1=1.00014-0.01672*COS(m)-0.0014*COS(2*m)
  144. r2=5.20867-0.25192*COS(n)-0.0061*COS(2*n)
  145. d3=SQR(r1^2+r2^2-2*r1*r2*COS(k))
  146. CALL arcsin(5.24259e-315/d3,s4)
  147. semidiameter=5.39085e-315*s4
  148. s2=r1*SIN(k)/d3
  149. CALL arcsin(s2,s3)
  150. l1=4.15476+0.0014502*d2+0.00576*SIN(v)+p
  151. a=0.05358*SIN(l1+0.77667)
  152. d4=a-0.03752*s2*COS(l1+0.4189)-0.02286*((r2-d3)/d3)*SIN(l1-1.73486)
  153. a=d2-d3/173.145
  154. u(1)=FNdemod(1.47569+5.309e-315*a+s3-p)
  155. u(2)=FNdemod(0.724338+5.30379e-315*a+s3-p)
  156. u(3)=FNdemod(5.30457e-315+5.29853e-315*a+s3-p)
  157. u(4)=FNdemod(5.30778e-315+5.29204e-315*a+s3-p)
  158. g=FNdemod(3.269+5.29855e-315*a)
  159. h=FNdemod(5.4297+5.29207e-315*a)
  160. r(1)=5.9061-0.0244*COS(2*(u(1)-u(2)))
  161. r(2)=9.3972-0.0889*COS(2*(u(2)-u(3)))
  162. r(3)=14.9894-0.0227*COS(g)
  163. r(4)=26.3649-0.1944*COS(h)
  164. u(1)=FNdemod(u(1)+0.0082296*SIN(2*(u(1)-u(2))))
  165. u(2)=FNdemod(u(2)+0.018727*SIN(2*(u(2)-u(3))))
  166. u(3)=FNdemod(u(3)+0.003037*SIN(g))
  167. u(4)=FNdemod(u(4)+0.014748*SIN(h))
  168. FOR i%=1 TO 4
  169.  x(i%)=r(i%)*SIN(u(i%))
  170.  y(i%)=-r(i%)*COS(u(i%))*SIN(d4)
  171. NEXT i%
  172. END SUB
  173.  
  174. SUB arcsin(sinangle,angle) STATIC
  175. ' inverse sine subroutine
  176. SHARED pidiv2
  177. IF ABS(sinangle)>=1 THEN
  178.  angle=SGN(sinangle))*pidiv2
  179. ELSE
  180.  angle=ATN(sinangle/SQR(1-sinangle^2))
  181. END IF
  182. END SUB
  183.  
  184. SUB Gregorian.date(jdate) STATIC
  185. ' Gregorian Date subroutine
  186. SHARED month%,day%,year%,cdate$
  187. IF jdate<5.4091e-315 THEN
  188.  a=jdate
  189. ELSE 
  190.  a=INT((jdate-5.40747e-315)/36524.2)
  191.  a=jdate+a-INT(a/4)+1
  192. END IF
  193. b=a+1524
  194. c=INT((b-122.1)/365.25)
  195. d=INT(365.25*c)
  196. e=INT((b-d)/30.6001)
  197. day%=b-d-INT(30.6001*e)
  198. IF e<13.5 THEN month%=e-1 :ELSE month%=e-13
  199. IF month%>2.5 THEN year%=c-4716 :ELSE year%=c-4715
  200. cdate$=month$(month%)+STR$(day%)+","+STR$(year%)
  201. END SUB
  202.  
  203. SUB selection.menu(selection%) STATIC
  204. ' selection menu subroutine
  205. WINDOW 4,"Galilean Menu",(0,0)-(480,35),0,1
  206. LOCATE 1,1:PRINT PTAB(40);"please press left mouse button to select"
  207. LINE (10,14)-(148,30),1,b
  208. LINE (172,14)-(268,30),1,b
  209. LINE (292,14)-(392,30),1,b
  210. LINE (416,14)-(466,30),1,b
  211. LOCATE 3,1:PRINT PTAB(20);"Display Data";PTAB(180);"Graphics";
  212. PRINT PTAB(300);"Continue";PTAB(426);"End";
  213. selection%=-1 
  214. WHILE selection%=-1
  215.  WHILE MOUSE(0)=0:WEND
  216.  mx=MOUSE(1):my=MOUSE(2)
  217.  IF (mx>10 AND mx<148) AND (my>14 AND my<30) THEN
  218.   selection%=1
  219.   WHILE MOUSE(0)<>0:WEND
  220.  END IF 
  221.  IF (mx>172 AND mx<268) AND (my>14 AND my<30) THEN
  222.   selection%=2
  223.   WHILE MOUSE(0)<>0:WEND
  224.  END IF
  225.  IF (mx>292 AND mx<392) AND (my>14 AND my<30) THEN
  226.   selection%=3
  227.   WHILE MOUSE(0)<>0:WEND
  228.  END IF 
  229.  IF (mx>416 AND mx<466) AND (my>14 AND my<30) THEN
  230.   selection%=4
  231.   WHILE MOUSE(0)<>0:WEND
  232.  END IF 
  233.  WEND 
  234. WINDOW CLOSE 4
  235. END SUB
  236.  
  237. SUB yesno.menu(request$,response%) STATIC
  238. ' yes/no request subroutine
  239. WINDOW 4,request$,(0,0)-(215,45),0,1
  240. LOCATE 1,1:PRINT PTAB(25);"press left mouse"
  241. LOCATE 2,1:PRINT PTAB(25);"button to select"
  242. LINE (20,20)-(80,40),1,b
  243. LINE (140,20)-(190,40),1,b
  244. LOCATE 4,1:PRINT PTAB(35);"Yes";PTAB(155);"No";
  245. response%=-1 
  246. WHILE response%=-1
  247.  WHILE MOUSE(0)=0:WEND
  248.  mx=MOUSE(1):my=MOUSE(2)
  249.  IF (mx>20 AND mx<80) AND (my>20 AND my<40) THEN
  250.   response%=1
  251.   WHILE MOUSE(0)<>0:WEND
  252.  END IF 
  253.  IF (mx>140 AND mx<190) AND (my>20 AND my<40) THEN
  254.   response%=2
  255.   WHILE MOUSE(0)<>0:WEND
  256.  END IF
  257. WEND
  258. WINDOW CLOSE 4
  259. END SUB
  260.  
  261. SUB Display.data STATIC
  262. ' display data subroutine
  263. SHARED cdate$,local.time$,julian.date,semidiameter,rad.to.deg
  264. WINDOW 4,"Galilean Data               (press left mouse button to continue)",(0,0)-(630,185),0,1
  265. PRINT
  266. COLOR 1,0
  267. PRINT TAB(5);"Date";TAB(60-LEN(cdate$));cdate$
  268. PRINT
  269. COLOR 2,0
  270. PRINT TAB(5);"Time";TAB(60-LEN(local.time$));local.time$
  271. PRINT
  272. COLOR 3,0
  273. PRINT TAB(5);"Julian Date";
  274. LOCATE 6,48
  275. PRINT USING "########.###";julian.date
  276. PRINT
  277. COLOR 4,0
  278. PRINT TAB(5);"Semidiameter (arc seconds)";
  279. LOCATE 8,48
  280. PRINT USING "########.###";semidiameter
  281. PRINT
  282. PRINT
  283. COLOR 7,0
  284. PRINT TAB(5);"Satellite       X-position       Y-position       Angle"
  285. PRINT TAB(5);"---------       ----------       ----------       -----"
  286. FOR i%=1 TO 4
  287. a$=STR$(INT(u(i%)*rad.to.deg))
  288. PRINT
  289. COLOR i%+2,0
  290. PRINT TAB(5);satellite$(i%);
  291. LOCATE ,22
  292. PRINT USING "###.###";x(i%);
  293. LOCATE ,39
  294. PRINT USING "###.###";y(i%);
  295. PRINT TAB(59-LEN(a$));a$
  296. NEXT i%
  297. WHILE MOUSE(0)=0:WEND
  298. WHILE MOUSE(0)<>0:WEND
  299. WINDOW CLOSE 4
  300. END SUB
  301.  
  302. SUB Graphics STATIC
  303. ' graphics subroutine
  304. SHARED cdate$,local.time$
  305. WINDOW 4,"Galilean Graphics           (press left mouse button to continue)",(0,0)-(630,185),0,1
  306. PRINT
  307. COLOR 1,0
  308. PRINT TAB(5);cdate$;
  309. PRINT TAB(60-LEN(local.time$));local.time$
  310. COLOR 2,0
  311. PRINT PTAB(290);"North"
  312. LOCATE 9,1
  313. PRINT TAB(56);"West"
  314. a$="JUPITER"
  315. COLOR 3,0
  316. LOCATE 5,1
  317. FOR j=1 TO 7
  318.  PRINT PTAB(310);MID$(a$,j,1)
  319. NEXT j
  320. CIRCLE (315,110),10,3
  321. PAINT (315,110),3
  322. LOCATE 15,1
  323. FOR i%=1 TO 4
  324.  COLOR i%+3,0
  325.  x=315+10*x(i%)
  326.  y=110-4.4444*y(i%)
  327.  s$="^ "+satellite$(i%)
  328.  CIRCLE (x,y),5
  329.  PAINT (x,y)
  330.  IF (x+LEN(s$))>550 THEN
  331.   s$=satellite$(i%)+" ^"
  332.   x=x-9*LEN(s$)
  333.  END IF 
  334.  PRINT PTAB(x-3);s$ 
  335. NEXT i%
  336. WHILE MOUSE(0)=0:WEND
  337. WHILE MOUSE(0)<>0:WEND
  338. WINDOW CLOSE 4
  339. END SUB
  340.   
  341. SUB Introduction STATIC
  342. ' program introduction subroutine
  343. CLS
  344. PRINT
  345. PRINT TAB(4);"GALILEAN is an interactive AmigaBasic program which can be"
  346. PRINT TAB(4);"used to determine the position of the Galilean satellites"
  347. PRINT TAB(4);"relative to Jupiter. This information is useful for such"
  348. PRINT TAB(4);"activities as astronomical observations, astrophotography"
  349. PRINT TAB(4);"and the study of occultations between the moons."
  350. PRINT
  351. PRINT TAB(4);"This program provides the position of each of the four"
  352. PRINT TAB(4);"Galilean moons in the units of the radius of Jupiter. The"
  353. PRINT TAB(4);"x-position of each satellite is measured positive west of"
  354. PRINT TAB(4);"Jupiter and the y-position is measured positive north."
  355. PRINT TAB(4);"It also calculates the 'position angle' of each satellite."
  356. PRINT TAB(4);"This angle helps determine if any of the satellites are"
  357. PRINT TAB(4);"in front of or behind Jupiter. A position angle near 0"
  358. PRINT TAB(4);"or 360 degrees is called 'inferior conjunction' and an"
  359. PRINT TAB(4);"angle near 180 degrees is called 'superior conjunction'."
  360. PRINT TAB(4);"A satellite is in front of Jupiter at inferior conjunction"
  361. PRINT TAB(4);"and behind Jupiter at superior conjunction."
  362. CALL nextpage
  363. CLS
  364. PRINT
  365. PRINT TAB(4);"Inputs required by program 'GALILEAN' include the user's"
  366. PRINT TAB(4);"observation date, the local time and time zone. The user"
  367. PRINT TAB(4);"must also specify if Daylight Savings Time is in effect."
  368. PRINT TAB(4);"The date is input in numerical format and the local time"
  369. PRINT TAB(4);"in 24 hour format. The time zone will be an integer number"
  370. PRINT TAB(4);"between 0 and 23."
  371. PRINT
  372. PRINT TAB(4);"The 'Galilean Menu' will allow the user to display the"
  373. PRINT TAB(4);"data and/or graphics for the selected date. The 'Continue'"
  374. PRINT TAB(4);"selection of this menu will calculate the information for"
  375. PRINT TAB(4);"the next day. The user can then choose to display data or"
  376. PRINT TAB(4);"and/or graphics for the new date. Please note that you can"
  377. PRINT TAB(4);"leave the data and graphics display by pressing the left"
  378. PRINT TAB(4);"mouse button. The 'End' selection of the 'Galilean Menu'"
  379. PRINT TAB(4);"will allow you to end the current session and select a new"
  380. PRINT TAB(4);"date and/or time."
  381. CALL nextpage
  382. END SUB
  383.  
  384. SUB nextpage STATIC
  385. ' select next page subroutine
  386. PRINT
  387. PRINT TAB(13);"< press left mouse button to continue >"
  388. WHILE MOUSE(0)=0:WEND
  389. WHILE MOUSE(0)<>0:WEND
  390. END SUB
  391.      
  392.